package com.file.system.tools.rand;

/**
 * Created by admin on 2020/5/13.
 */
public class RandomNumberCode {

    /**
     * @Description [jch] [获取随机符号 1+ 2- 3* 4/]
     * @Param
     * @Return
     * @Date 2020/5/13 15:09
     */
    public static int randomSymbol() {
        int symbol = (int) (Math.random() * 4 + 1);
        return symbol;
    }

    /**
     * @Description [jch] [获取第二个数字]
     * @Param
     * @Return
     * @Date 2020/5/13 15:18
     */
    public static int randomSecond() {
        int second = (int) (Math.random() * 30);
        return second;
    }

    /**
     * @Description [jch] [获取第一个数字]
     * @Param
     * @Return
     * @Date 2020/5/13 15:19
     */
    public static int randomFirst(int symbol, int second) {
        int first = 0;
        //加法
        if (symbol == 1) first = (int) (Math.random() * 50) + (int) (Math.random() * 5 + 1);
        //减法
        if (symbol == 2) first = second * (int) (Math.random() * 3 + 10);
        //乘法
        if (symbol == 3) first = (int) (Math.random() * 5);
        //除法
        if (symbol == 4) first = second * ((int) (Math.random() * 5 + 1));
        return first;
    }


    public static void main(String[] args) {
        int symbol = randomSymbol();
        int second = randomSecond();
        int first = randomFirst(symbol, second);
        int result = 0;
        if (symbol == 1) {
            System.out.println("加法" + first + "+" + second);
            result = first + second;
        }
        if (symbol == 2) {
            System.out.println("减法" + first + "-" + second);
            result = first - second;
        }
        if (symbol == 3) {
            System.out.println("乘法" + first + "×" + second);
            result = first * second;
        }
        if (symbol == 4) {
            System.out.println("除法" + first + "÷" + second);
            result = first / second;
        }
        System.out.println(result);
    }


}
